package com.zzyl.controller.customer;

import com.aliyun.iot20180120.models.QueryDevicePropertyStatusRequest;
import com.aliyun.iot20180120.models.QueryDevicePropertyStatusResponseBody;
import com.zzyl.base.ResponseResult;
import com.zzyl.controller.BaseController;
import com.zzyl.dto.DeviceDataByDayDto;
import com.zzyl.dto.UserLoginRequestDto;
import com.zzyl.service.DeviceDataService;
import com.zzyl.service.DeviceService;
import com.zzyl.service.MemberService;
import com.zzyl.vo.DeviceDataGraphVo;
import com.zzyl.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Api(tags = "客户管理")
@RestController
@RequestMapping("/customer/user")
public class CustomerUserController extends BaseController {

    @Autowired
    MemberService memberService;

    @Autowired
    DeviceService deviceService;

    @Autowired
    DeviceDataService deviceDataService;
    /**
     * C端用户登录--微信登录
     *
     * @param userLoginRequestDto 用户登录信息
     * @return ResponseResult
     */
    @PostMapping("/login")
    @ApiOperation("登录")
    public ResponseResult login(@RequestBody UserLoginRequestDto userLoginRequestDto) {
        LoginVo login = memberService.login(userLoginRequestDto);
        return success(login);
    }

    @PostMapping("/QueryDevicePropertyStatus")
    public ResponseResult QueryDevicePropertyStatus(@RequestBody QueryDevicePropertyStatusRequest dto){
        QueryDevicePropertyStatusResponseBody.QueryDevicePropertyStatusResponseBodyData resout =deviceService.queryDevicePropertyStatus(dto);
        return success(resout);
    }

    @GetMapping("/queryDeviceDataListByDay")
    public ResponseResult queryDeviceDataListByDay(DeviceDataByDayDto dto){
        List<DeviceDataGraphVo> resout = deviceDataService.getDeviceDateListByDay(dto);
        return success(resout);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    public ResponseResult queryDeviceDataListByWeek(DeviceDataByDayDto dto){
        List<DeviceDataGraphVo> resout = deviceDataService.queryDeviceDataListByWeek(dto);
        return success(resout);
    }
}